package com.bbva.kyfb.kyfbjpatlsb.dominiotlsb;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbool.
 */
@Configurable
@Entity
@Table(name = "TTLSBOOL",schema = "TLSB")
@RooJavaBean
@RooToString
@RooEntity(identifierType = TtlsboolPK.class, versionField = "", persistenceUnit="persistenceUnitTLSB",table = "TTLSBOOL", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLSB")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbool {

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("CodBancoint: ").append(getCodBancoint()).append(", ");
        sb.append("CodCanaldi: ").append(getCodCanaldi()).append(", ");
        sb.append("CodLogonapl: ").append(getCodLogonapl()).append(", ");
        sb.append("CodTipord: ").append(getCodTipord()).append(", ");
        sb.append("DesOrdenol: ").append(getDesOrdenol()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("XsnOrdeneje: ").append(getXsnOrdeneje());
        return sb.toString();
    }

	/** The des ordenol. */
	@Column(name = "DES_ORDENOL", columnDefinition = "VARCHAR", length = 500)
    @NotNull
    private String desOrdenol;

	/** The cod tipord. */
	@Column(name = "COD_TIPORD", columnDefinition = "CHAR", length = 4)
    @NotNull
    private String codTipord;

	/** The aud fmodific. */
	@Column(name = "AUD_FMODIFIC", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	/** The aud usuario. */
	@Column(name = "AUD_USUARIO", columnDefinition = "CHAR", length = 8)
    @NotNull
    private String audUsuario;

	/** The xsn ordeneje. */
	@Column(name = "XSN_ORDENEJE", columnDefinition = "CHAR")
    private Character xsnOrdeneje;

	/** The cod canaldi. */
	@Column(name = "COD_CANALDI", columnDefinition = "SMALLINT")
    private Short codCanaldi;

	/** The cod bancoint. */
	@Column(name = "COD_BANCOINT", columnDefinition = "SMALLINT")
    private Short codBancoint;

	/** The cod logonapl. */
	@Column(name = "COD_LOGONAPL", columnDefinition = "CHAR", length = 20)
    private String codLogonapl;

	/**
	 * Gets the des ordenol.
	 *
	 * @return the des ordenol
	 */
	public String getDesOrdenol() {
        return this.desOrdenol;
    }

	/**
	 * Sets the des ordenol.
	 *
	 * @param desOrdenol the new des ordenol
	 */
	public void setDesOrdenol(String desOrdenol) {
        this.desOrdenol = desOrdenol;
    }

	/**
	 * Gets the cod tipord.
	 *
	 * @return the cod tipord
	 */
	public String getCodTipord() {
        return this.codTipord;
    }

	/**
	 * Sets the cod tipord.
	 *
	 * @param codTipord the new cod tipord
	 */
	public void setCodTipord(String codTipord) {
        this.codTipord = codTipord;
    }

	/**
	 * Gets the aud fmodific.
	 *
	 * @return the aud fmodific
	 */
	public Date getAudFmodific() {
        return this.audFmodific;
    }

	/**
	 * Sets the aud fmodific.
	 *
	 * @param audFmodific the new aud fmodific
	 */
	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }

	/**
	 * Gets the aud usuario.
	 *
	 * @return the aud usuario
	 */
	public String getAudUsuario() {
        return this.audUsuario;
    }

	/**
	 * Sets the aud usuario.
	 *
	 * @param audUsuario the new aud usuario
	 */
	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	/**
	 * Gets the xsn ordeneje.
	 *
	 * @return the xsn ordeneje
	 */
	public Character getXsnOrdeneje() {
        return this.xsnOrdeneje;
    }

	/**
	 * Sets the xsn ordeneje.
	 *
	 * @param xsnOrdeneje the new xsn ordeneje
	 */
	public void setXsnOrdeneje(Character xsnOrdeneje) {
        this.xsnOrdeneje = xsnOrdeneje;
    }

	/**
	 * Gets the cod canaldi.
	 *
	 * @return the cod canaldi
	 */
	public Short getCodCanaldi() {
        return this.codCanaldi;
    }

	/**
	 * Sets the cod canaldi.
	 *
	 * @param codCanaldi the new cod canaldi
	 */
	public void setCodCanaldi(Short codCanaldi) {
        this.codCanaldi = codCanaldi;
    }

	/**
	 * Gets the cod bancoint.
	 *
	 * @return the cod bancoint
	 */
	public Short getCodBancoint() {
        return this.codBancoint;
    }

	/**
	 * Sets the cod bancoint.
	 *
	 * @param codBancoint the new cod bancoint
	 */
	public void setCodBancoint(Short codBancoint) {
        this.codBancoint = codBancoint;
    }

	/**
	 * Gets the cod logonapl.
	 *
	 * @return the cod logonapl
	 */
	public String getCodLogonapl() {
        return this.codLogonapl;
    }

	/**
	 * Sets the cod logonapl.
	 *
	 * @param codLogonapl the new cod logonapl
	 */
	public void setCodLogonapl(String codLogonapl) {
        this.codLogonapl = codLogonapl;
    }

	/** The entity manager. */
//	@PersistenceContext
	@PersistenceContext(unitName = "persistenceUnitTLSB")
    transient EntityManager entityManager;

	/** The id. */
	@EmbeddedId
    private TtlsboolPK id;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public TtlsboolPK getId() {
        return this.id;
    }

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(TtlsboolPK id) {
        this.id = id;
    }

	/**
	 * Persist.
	 */
	@Transactional(value="tlsb")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	/**
	 * Removes the.
	 */
	@Transactional(value="tlsb")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbool attached = Ttlsbool.findTtlsbool(this.id);
            this.entityManager.remove(attached);
        }
    }

	/**
	 * Flush.
	 */
	@Transactional(value="tlsb")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	/**
	 * Clear.
	 */
	@Transactional(value="tlsb")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	/**
	 * Merge.
	 *
	 * @return the ttlsbool
	 */
	@Transactional(value="tlsb")
    public Ttlsbool merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbool merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	/**
	 * Entity manager.
	 *
	 * @return the entity manager
	 */
	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbool().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	
	/**
	 * Count ttlsbools.
	 *
	 * @return the long
	 */
	@Transactional(value="tlsb")
	public static long countTtlsbools() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbool o", Long.class).getSingleResult();
    }

	
	/**
	 * Find all ttlsbools.
	 *
	 * @return the list
	 */
	@Transactional(value="tlsb")
	public static List<Ttlsbool> findAllTtlsbools() {
        return entityManager().createQuery("SELECT o FROM Ttlsbool o", Ttlsbool.class).getResultList();
    }

	
	/**
	 * Find ttlsbool.
	 *
	 * @param id the id
	 * @return the ttlsbool
	 */
	@Transactional(value="tlsb")
	public static Ttlsbool findTtlsbool(TtlsboolPK id) {
        if (id == null) return null;
        return entityManager().find(Ttlsbool.class, id);
    }

	
	/**
	 * Find ttlsbool entries.
	 *
	 * @param firstResult the first result
	 * @param maxResults the max results
	 * @return the list
	 */
	@Transactional(value="tlsb")
	public static List<Ttlsbool> findTtlsboolEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbool o", Ttlsbool.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }
}
